package com.bc.bcmodel.domain;

import java.math.BigInteger;

/**
 * Created by lianzerong on 2018/8/3.
 */
public class T_SequenceModelExt extends T_SequenceModel {

    /**
     * 序列值
     */
    private BigInteger old_seq_value;

    public T_SequenceModelExt() {
    }

    public T_SequenceModelExt(T_SequenceModel sequence) {
        this.setGmt_create(sequence.getGmt_create());
        this.setGmt_modified(sequence.getGmt_modified());
        this.setId(sequence.getId());
        this.setMax_value(sequence.getMax_value());
        this.setMin_value(sequence.getMin_value());
        this.setMemo(sequence.getMemo());
        this.setSeq_name(sequence.getSeq_name());
        this.setSeq_value(sequence.getSeq_value());
        this.setStep(sequence.getStep());
    }

    public Long newSeqValue() {
        long newSeqValue = getSeq_value().add(getStep()).longValue();
        if (newSeqValue < getMin_value().longValue() || newSeqValue > getMax_value().longValue()) {
            newSeqValue = 0 + getStep().longValue();
        }
        return newSeqValue;
    }

    public BigInteger getOld_seq_value() {
        return old_seq_value;
    }

    public void setOld_seq_value(BigInteger old_seq_value) {
        this.old_seq_value = old_seq_value;
    }

}
